/*
========================================================================
 Name        : Mp3Player.cpp
 Author      : 
 Copyright   : Your copyright notice
 Description : 
========================================================================
*/
#include "Mp3Player.h"

_LIT( KAudioFile, "c:\\data\\sounds\\a.mp3");

CMp3Player::CMp3Player(): iPlayer( NULL )
	{
	iState = (TInt)ENotReady;
	}

void CMp3Player::ConstructL()
	{
	iPlayer = CMdaAudioPlayerUtility::NewFilePlayerL( KAudioFile, *this );
	}

CMp3Player::~CMp3Player()
	{
	delete iPlayer;
	iPlayer = NULL;
	}

CMp3Player* CMp3Player::NewL()
	{
	CMp3Player* self = new (ELeave)CMp3Player;
	CleanupStack::PushL( self );
	self->ConstructL();
	CleanupStack::Pop();
	return self;
	}

void CMp3Player::MapcInitComplete(TInt aError, 
		const TTimeIntervalMicroSeconds& /*aDuration*/)
	{
	User::LeaveIfError( aError );
	iState = (TInt)EReady;
	}

void CMp3Player::MapcPlayComplete( TInt aError )
	{
	User::LeaveIfError( aError );
	iState = (TInt)EReady;
	}

void CMp3Player::Play()
	{
	if( iState == (TInt)EReady )
		{
		iState  = (TInt)EPlaying;
		iPlayer->Play();
		}
	}
